package com.project.controller;

import com.project.bean.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;

@Controller
@RequestMapping("test")
public class TestController  {

    @RequestMapping("checkName")
    public void checkName(String name , HttpServletResponse response) throws Exception {
        if ("java".equals(name)) {
            response.getWriter().print("no");
        } else {
            response.getWriter().print("yes");
        }
    }

    @RequestMapping("getString")
    @ResponseBody
    public String getString(){
        return  "ok中国人";//加上注解@ResponseBody，即可以打印，不加则无法打印，因为返回的是网页地址
    }


    @RequestMapping("getUser")
    @ResponseBody
    public UserBean getUser(){

        return new UserBean(1,"嘿嘿", LocalDate.parse("1998-07-09"));
    }
}
